﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Drawing;

namespace BinaryTree
{
    public class VDraw:IVisitDraw
    {
        public static Graphics _graphics;
        Brush b = new HatchBrush(HatchStyle.Percent05, Color.Black);
        Brush c = new HatchBrush(HatchStyle.Percent90, Color.Red);
        Pen pen = new Pen(Color.FromArgb(255, 8, 6, 9), 1);
        private int dy = 50;
        public void Visit(treeNode _root, int x, int y, int xp, int dx)
        {
            if (_root == null) return;
            _graphics.DrawLine(pen, x, y, xp, y + dy);
            _graphics.FillRectangle(b, xp - 20, y + dy, 40, 40);
            _graphics.DrawString(_root.value.ToString(), new Font("Microsoft Sans Serif", 14), c, xp - 10, y + 12 + dy);
        }
    }
}
